package project_package;

public class SalesLineItem {

	Product product;
	int quantity;
	
	public SalesLineItem(Product product, int quantity)
	{
		this.product = product;
		this.quantity = quantity;
	}
	
	// gets wanted quantity
	public int getQuantity()
	{
		return quantity;
	}
	
	// sets wanted quantity
	public void setQuantity(int quantity)
	{
		this.quantity = quantity;
	}
	
	// gets product
	public Product getProduct() 
	{
		return product;
	}
	
	// gets product's price according to how many items we've purchased
	public double getLinePrice() 
	{
		double price = 0.0;
		price = product.getPrice() * quantity;
		return price;
	}
	
	// gets product's price according to how many items we've purchased with discount
	public double getLinePriceDiscount()
	{
		double price = 0.0;
		// getPrice() returns the product price
		// getDiscount() returns the product's discount
		// if price is 100 and we have discount of 20% mathematically it would look like:
		// 100 - 0,2*100 = 100 - 20 = 80
		// price - discount in decimals*price 
		// to get the total price of the current line item we multiply by the quantity
		price = (product.getPrice()-(product.getPrice()*product.getDiscount())) * quantity;
		return price;
	}
}